home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 October / Macworld (1998-10).dmg / Serious Demos / Morpha / 3DO.DXR / 00003_3d object behaviour.ls < prev    next >
Encoding:
Text File  |  1998-07-31  |  1.8 KB  |  91 lines

  1. property mys, mygroup, x, y, z, mywidth, myheight, xadd, yadd, zadd, rx, ry, rz, mymember
  2. global xoff, yoff, zoff, scale, grouper
  3.  
  4. on beginSprite me
  5.   set mys to the spriteNum of me
  6.   set rx to 0
  7.   set ry to 0
  8.   set rz to 0
  9.   set xadd to 0
  10.   set yadd to 0
  11.   set zadd to 0
  12.   set mymember to the member of sprite mys
  13.   set mywidth to the width of the member of sprite mys
  14.   set myheight to the height of the member of sprite mys
  15. end
  16.  
  17. on exitFrame me
  18.   set rx to rx * 0.80000000000000004
  19.   set ry to ry * 0.80000000000000004
  20.   set rz to rz * 0.80000000000000004
  21.   rotate(me)
  22.   View_point(me)
  23. end
  24.  
  25. on xfix me, gx
  26.   set rx to gx
  27. end
  28.  
  29. on yfix me, gy
  30.   set ry to gy
  31. end
  32.  
  33. on zfix me, gz
  34.   set rz to gz
  35. end
  36.  
  37. on plot me, tx, ty, tz
  38.   set x to tx
  39.   set y to ty
  40.   set z to tz
  41. end
  42.  
  43. on movepoint me, group, xamount, yamount, zamount
  44.   case grouper of
  45.     mygroup, 0:
  46.       set xadd to xadd + xamount
  47.       set yadd to yadd + yamount
  48.       set zadd to zadd + zamount
  49.   end case
  50. end
  51.  
  52. on rotate me
  53.   if rx = 0 then
  54.   else
  55.     set cr to cos(rx)
  56.     set sr to sin(rx)
  57.     set y2 to (y * cr) - (z * sr)
  58.     set z2 to (y * sr) + (z * cr)
  59.     set y to y2
  60.     set z to z2
  61.   end if
  62.   if ry = 0 then
  63.   else
  64.     set cr to cos(ry)
  65.     set sr to sin(ry)
  66.     set x2 to (x * cr) + (z * sr)
  67.     set z2 to (z * cr) - (x * sr)
  68.     set x to x2
  69.     set z to z2
  70.   end if
  71.   if rz = 0 then
  72.   else
  73.     set cr to cos(rz)
  74.     set sr to sin(rz)
  75.     set x2 to (x * cr) - (y * sr)
  76.     set y2 to (y * cr) + (x * sr)
  77.     set x to x2
  78.     set y to y2
  79.   end if
  80. end
  81.  
  82. on View_point me
  83.   set z1 to z + zoff + zadd
  84.   set xp to (x + xadd) * scale / z1
  85.   set yp to (y + yadd) * scale / z1
  86.   set the locH of sprite mys to xp + xoff
  87.   set the locV of sprite mys to yoff - yp
  88.   set the width of sprite mys to mywidth * scale / z1
  89.   set the height of sprite mys to myheight * scale / z1
  90. end
  91.